package com.mission.schedule.adapter;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Handler;
import android.os.Message;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mission.schedule.R;
import com.mission.schedule.applcation.App;
import com.mission.schedule.constants.ShareFile;
import com.mission.schedule.cutimage.Log;
import com.mission.schedule.entity.ScheduleTable;
import com.mission.schedule.my160920.SwipeLayout;
import com.mission.schedule.my160920.bean.LyNewNumBean;
import com.mission.schedule.utils.CharacterUtil;
import com.mission.schedule.utils.DateUtil;
import com.mission.schedule.utils.SharedPrefUtil;
import com.mission.schedule.utils.StringUtils;
import com.mission.schedule.utils.Utils;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by liwei on 22/12/2016.
 */

public class MyScheduleNewAdapter extends BaseAdapter {

    private Context context;
    private List<Map<String, String>> mList;
    private Handler handler;
    int uncount = 0;// 今日待办个数
    int todaycount = 0;// 今日日程个数
    int tomorrowcount = 0;// 明天日程个数
    int inweekcount = 0;// 一周以内日程个数
    int outweekcount = 0;// 一周以外日程个数
    String localpath = "0";// 本地存储的背景
    String outweekfag = "0";// 判断一周后展示布局是否显示
    int width = 0;
    SharedPrefUtil sharedPrefUtil = null;
    List<Map<String, String>> outweekList = null;

    private String S4 = "GT-I9500";//android.os.Build.MODEL
    /**
     * 消息状态
     */
    private List<LyNewNumBean.ListBean> listBeanList = new ArrayList<>();

    public MyScheduleNewAdapter(Context context, List<Map<String, String>> lDatas, Handler handler,
                                int uncount, int todaycount, int tomorrowcount, int inweekcount,
                                int outweekcount, String localpath, String outweekfag, int width) {
        this.context = context;
        this.mList = lDatas;
        this.handler = handler;
        this.uncount = uncount;
        this.todaycount = todaycount;
        this.tomorrowcount = tomorrowcount;
        this.inweekcount = inweekcount;
        this.outweekcount = outweekcount;
        this.localpath = localpath;
        this.outweekfag = outweekfag;
        this.width = width;
        sharedPrefUtil = new SharedPrefUtil(context, ShareFile.USERFILE);
        outweekList = new ArrayList<Map<String, String>>();
    }

    private void setOnclick(int positions, Map<String, String> map, int what, int type) {
        Message message = Message.obtain();
        message.arg1 = positions;
        message.arg2 = type;
        message.obj = map;
        message.what = what;
        handler.sendMessage(message);
    }


    @Override
    public int getCount() {
        return mList == null ? 0 : mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.adapter_timeall_item_new, null, false);
            holder.swipeLayout = (SwipeLayout) convertView.findViewById(R.id.sch_sl);
            //添加侧滑
            SwipeLayout.addSwipeView(holder.swipeLayout);

            holder.top_ll = (LinearLayout) convertView.findViewById(R.id.top_ll);
            holder.timeall_ll = (LinearLayout) convertView.findViewById(R.id.timeall_ll); // 标题栏，包含今天，日期，农历等
            holder.timeall_tv_month = (TextView) convertView.findViewById(R.id.timeall_tv_month); // 日期
            // 如：08-31
            holder.timeall_tv_week = (TextView) convertView.findViewById(R.id.timeall_tv_week); // 周几
            // 如：周二
            holder.timeall_tv_daycount = (TextView) convertView.findViewById(R.id.timeall_tv_daycount); // 今天，明天，几天后
            holder.timeall_rela_right = (LinearLayout) convertView.findViewById(R.id.timeall_rela_right); // 下面整体布局
            holder.timeall_tv_time = (TextView) convertView.findViewById(R.id.timeall_tv_time); // 时间
            // 如：全天或08：00
            holder.timeall_tv_shun = (TextView) convertView.findViewById(R.id.timeall_tv_shun); // 顺延
            // 如：顺
            holder.timeall_tv_lastday = (TextView) convertView.findViewById(R.id.timeall_tv_lastday); // 多少小时后，多少天后
            holder.timeall_tv_content = (TextView) convertView.findViewById(R.id.timeall_tv_content); // 日程内容
            // TextView timeall_tv_has = ()convertView.findViewById(R.id.timeall_tv_has); //
            // 标题栏天后
            holder.personstate_tv = (TextView) convertView.findViewById(R.id.personstate_tv);// 公开状态
            holder.tv_delete = (TextView) convertView.findViewById(R.id.tv_delete);// 删除
            holder.guoqi_img = (ImageView) convertView.findViewById(R.id.guoqi_img);// 过期未结束图标，在今天中才显示
            holder.comename_tv = (TextView) convertView.findViewById(R.id.comename_tv);// 来自谁的日程
            holder.datebackground_ll = (LinearLayout) convertView.findViewById(R.id.datebackground_ll);// 今天和日期的背景
            holder.select_cb = (CheckBox) convertView.findViewById(R.id.select_cb);
            holder.timeall_tv_nongli = (TextView) convertView.findViewById(R.id.timeall_tv_nongli);// 农历日期显示
            holder.bottom_month = (TextView) convertView.findViewById(R.id.bottom_month);
            holder.bottom_week = (TextView) convertView.findViewById(R.id.bottom_week);
            holder.select_cb_ll = (LinearLayout) convertView.findViewById(R.id.select_cb_ll);
            holder.outweek_ll = (LinearLayout) convertView.findViewById(R.id.outweek_ll);// 一周以后布局
            holder.outweekcount_tv = (TextView) convertView.findViewById(R.id.outweekcount_tv);
            holder.newcome_ll = (LinearLayout) convertView.findViewById(R.id.newcome_ll);
            holder.newcome_tv = (TextView) convertView.findViewById(R.id.newcome_tv);
            holder.timeall_after = (TextView) convertView.findViewById(R.id.timeall_after);// 标题栏几天后

            //new_img 好友日程状态
            holder.new_img = (ImageView) convertView.findViewById(R.id.new_img);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        final Map<String, String> mMap = mList.get(position);

        holder.timeall_rela_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 点击详情菜单
                setOnclick(position, mMap, 0, 0);
            }
        });
        holder.timeall_ll.setOnClickListener(new View.OnClickListener() {
            // 点击日历进入
            @Override
            public void onClick(View v) {
                setOnclick(position, mMap, 4, 0);
            }
        });
        holder.tv_delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 右滑删除
                setOnclick(position, mMap, 3, 0);
            }
        });
        holder.select_cb_ll.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // 选中表示结束
                Log.e("TAG",mMap.get(ScheduleTable.schIsEnd)+"  list:"+mList.get(position).get(ScheduleTable.schIsEnd));
                if (holder.select_cb.isChecked() == true) {

                    setOnclick(position, mMap, 2, 0);
                    mList.get(position).put(ScheduleTable.schIsEnd,"0");
                    mMap.put(ScheduleTable.schIsEnd,"0");
                    if ("1".equals(mMap.get(ScheduleTable.schIsImportant))) {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_important_end));
                    } else {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_end));
                    }
                    holder.timeall_tv_content.setTextColor(context.getResources().getColor(
                            R.color.endtextcolor));
                    holder.timeall_tv_time.setTextColor(context.getResources().getColor(
                            R.color.endtextcolor));
                    holder.bottom_month.setTextColor(context.getResources().getColor(
                            R.color.endtextcolor));
                    holder.bottom_week.setTextColor(context.getResources().getColor(
                            R.color.endtextcolor));
                    holder.timeall_tv_content.getPaint().setFlags(
                            Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
                } else {

                    setOnclick(position, mMap, 2, 1);
                    mList.get(position).put(ScheduleTable.schIsEnd,"1");
                    mMap.put(ScheduleTable.schIsEnd,"1");
                    if ("1".equals(mMap.get(ScheduleTable.schIsImportant))) {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_important));
                    } else {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_normal));
                    }
                    holder.timeall_tv_time.setTextColor(context.getResources().getColor(
                            R.color.mingtian_color));
                    holder.bottom_month.setTextColor(context.getResources().getColor(
                            R.color.mingtian_color));
                    holder.bottom_week.setTextColor(context.getResources().getColor(
                            R.color.mingtian_color));
                    holder.timeall_tv_content.setTextColor(Color.BLACK);
                    holder.timeall_tv_content.getPaint().setFlags(0 | Paint.ANTI_ALIAS_FLAG);

                }
            }
        });
//        holder.select_cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
//            @Override
//            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//                if (isChecked == true) {
//                    setOnclick(position, mMap, 2, 0);
//                    if ("1".equals(mMap.get(ScheduleTable.schIsImportant))) {
//                        holder.timeall_rela_right.setBackground(context.getResources()
//                                .getDrawable(R.drawable.bg_sch_important_end));
//                    } else {
//                        holder.timeall_rela_right.setBackground(context.getResources()
//                                .getDrawable(R.drawable.bg_sch_end));
//                    }
//                    holder.timeall_tv_content.setTextColor(Color.parseColor("#7F7F7F"));
//                    holder.timeall_tv_time.setTextColor(Color.parseColor("#7F7F7F"));
//                    holder.bottom_month.setTextColor(Color.parseColor("#7F7F7F"));
//                    holder.bottom_week.setTextColor(Color.parseColor("#7F7F7F"));
//                    holder.timeall_tv_content.getPaint().setFlags(
//                            Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
//                    holder.select_cb.setChecked(true);
//                } else {
//                    setOnclick(position, mMap, 2, 1);
//                    if ("1".equals(mMap.get(ScheduleTable.schIsImportant))) {
//                        holder.timeall_rela_right.setBackground(context.getResources()
//                                .getDrawable(R.drawable.bg_sch_important));
//                    } else {
//                        holder.timeall_rela_right.setBackground(context.getResources()
//                                .getDrawable(R.drawable.bg_sch_normal));
//                    }
//                    holder.timeall_tv_time.setTextColor(context.getResources().getColor(
//                            R.color.mingtian_color));
//                    holder.bottom_month.setTextColor(context.getResources().getColor(
//                            R.color.mingtian_color));
//                    holder.bottom_week.setTextColor(context.getResources().getColor(
//                            R.color.mingtian_color));
//                    holder.timeall_tv_content.setTextColor(Color.BLACK);
//                    holder.timeall_tv_content.getPaint().setFlags(0 | Paint.ANTI_ALIAS_FLAG);
//                    holder.select_cb.setChecked(false);
//                }
//            }
//        });
        holder.select_cb.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Log.e("TAG",mMap.get(ScheduleTable.schIsEnd)+"  list:"+mList.get(position).get(ScheduleTable.schIsEnd));
                // 选中表示结束
                if (holder.select_cb.isChecked() == true) {
                    setOnclick(position, mMap, 2, 0);
                    mList.get(position).put(ScheduleTable.schIsEnd,"0");
                    mMap.put(ScheduleTable.schIsEnd,"0");
                    if ("1".equals(mMap.get(ScheduleTable.schIsImportant))) {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_important_end));
                    } else {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_end));
                    }
                    holder.timeall_tv_content.setTextColor(context.getResources().getColor(
                            R.color.endtextcolor));
                    holder.timeall_tv_time.setTextColor(context.getResources().getColor(
                            R.color.endtextcolor));
                    holder.bottom_month.setTextColor(context.getResources().getColor(
                            R.color.endtextcolor));
                    holder.bottom_week.setTextColor(context.getResources().getColor(
                            R.color.endtextcolor));
                    holder.timeall_tv_content.getPaint().setFlags(
                            Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
                    holder.select_cb.setChecked(true);

                } else {
                    setOnclick(position, mMap, 2, 1);
                    mList.get(position).put(ScheduleTable.schIsEnd,"1");
                    mMap.put(ScheduleTable.schIsEnd,"1");
                    if ("1".equals(mMap.get(ScheduleTable.schIsImportant))) {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_important));
                    } else {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_normal));
                    }
                    holder.timeall_tv_time.setTextColor(context.getResources().getColor(
                            R.color.mingtian_color));
                    holder.bottom_month.setTextColor(context.getResources().getColor(
                            R.color.mingtian_color));
                    holder.bottom_week.setTextColor(context.getResources().getColor(
                            R.color.mingtian_color));
                    holder.timeall_tv_content.setTextColor(Color.BLACK);
                    holder.timeall_tv_content.getPaint().setFlags(0 | Paint.ANTI_ALIAS_FLAG);
                    holder.select_cb.setChecked(false);
                }
            }
        });
        holder.outweek_ll.setOnClickListener(new View.OnClickListener() {
            // 点击一周后
            @Override
            public void onClick(View v) {
                setOnclick(position, mMap, 5, 0);
                sharedPrefUtil.putString(context, ShareFile.USERFILE,
                        ShareFile.OUTWEEKFAG, "1");
                outweekfag = "1";
                holder.outweek_ll.setVisibility(View.GONE);
                holder.outweekcount_tv.setVisibility(View.GONE);
            }
        });
        String displayAlarm = mMap.get(ScheduleTable.schDisplayTime);
        String postpone = mMap.get(ScheduleTable.schIsPostpone);
        String alarmClockTime = mMap.get(ScheduleTable.schTime);
        String isEnd = mMap.get(ScheduleTable.schIsEnd);
        int beforTime = Integer.parseInt(mMap.get(ScheduleTable.schBeforeTime));
        String important = mMap.get(ScheduleTable.schIsImportant);

        String today, tomorrow, inweek;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        today = DateUtil.formatDateTime(calendar.getTime());
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) + 1);
        tomorrow = DateUtil.formatDateTime(calendar.getTime());
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) + 7);
        inweek = DateUtil.formatDateTime(calendar.getTime());
        if (position == 0) {
            try {
                outweekList = App.getDBcApplication().queryAllSchData(5, 0, 0);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (outweekList != null && outweekList.size() > 0) {
                outweekcount = outweekList.size();
            } else {
                outweekcount = 0;
            }
            if (mList != null && mList.size() > 0) {
                int untaskcount = 0;
                int todaytaskcount = 0;
                int tomorrowtaskcount = 0;
                int inweektaskcount = 0;
                for (int i = 0; i < mList.size(); i++) {
                    if (mList.get(i).get(ScheduleTable.schDate)
                            .equals(today.substring(0, 10))) {
                        if ("0".equals(mList.get(i).get(
                                ScheduleTable.schDisplayTime))
                                && "1".equals(mList.get(i).get(
                                ScheduleTable.schIsPostpone))) {
                            untaskcount = untaskcount + 1;
                        } else {
                            todaytaskcount = todaytaskcount + 1;
                        }
                    } else if (mList.get(i).get(ScheduleTable.schDate)
                            .equals(tomorrow.substring(0, 10))) {
                        tomorrowtaskcount = tomorrowtaskcount + 1;
                    } else if (DateUtil.parseDate(inweek.substring(0, 10))
                            .getTime() >= DateUtil.parseDate(
                            mList.get(i).get(ScheduleTable.schDate)).getTime()
                            && DateUtil.parseDate(
                            mList.get(i).get(ScheduleTable.schDate))
                            .getTime() > DateUtil.parseDate(tomorrow)
                            .getTime()) {
                        inweektaskcount = inweektaskcount + 1;
                    }
                }
                uncount = untaskcount;
                todaycount = todaytaskcount;
                tomorrowcount = tomorrowtaskcount;
                inweekcount = inweektaskcount;
            }
        }
        String key = mMap.get(ScheduleTable.schDate);
        String timeKey = mMap.get(ScheduleTable.schTime);

        Date dateStr = DateUtil.parseDateTime(key + " " + timeKey);
        String[] ymd = key.split("-");

        String clockTime = "";
        String point = "";
        String sequence = "";
        int shunBackKuang = 0;
        String colorState = "" + context.getResources().getColor(R.color.mingtian_color);
        String beforeStr = "";

        if (beforTime == 0) {
            beforeStr = "0";
        } else if (beforTime == 5) {
            beforeStr = "-5";
        } else if (beforTime == 15) {
            beforeStr = "-15";
        } else if (beforTime == 30) {
            beforeStr = "-30";
        } else if (beforTime == 60) {
            beforeStr = "-1h";
        } else if (beforTime == 120) {
            beforeStr = "-2h";
        } else if (beforTime == 1440) {
            beforeStr = "-1d";
        } else if (beforTime == 2 * 1440) {
            beforeStr = "-2d";
        } else if (beforTime == 7 * 1440) {
            beforeStr = "-1w";
        } else {
            beforeStr = "0";
        }

        if ("1".equals(isEnd)) {
            colorState = "#7F7F7F";// "#9f9f9f";
            shunBackKuang = R.drawable.tv_kuang_before;
        } else {
            if (today.substring(0, 10).equals(key)) {
                colorState = ""
                        + context.getResources().getColor(
                        R.color.mingtian_color);
            } else if (tomorrow.substring(0, 10).equals(key)) {
                colorState = ""
                        + context.getResources().getColor(
                        R.color.mingtian_color);
            } else {
                colorState = ""
                        + context.getResources().getColor(
                        R.color.mingtian_color);
            }

            shunBackKuang = R.drawable.tv_kuang_aftertime;
        }
        if (beforeStr.equals("0")) {
            clockTime = "<font color='" + colorState + "' size='5px'>"
                    + alarmClockTime + "</font>";
        } else {
            clockTime = "<font color='" + colorState + "' size='5px'>"
                    + alarmClockTime + "(" + beforeStr + ")" + "</font>";
        }
        // clockTime = "<font color='" + colorState + "' size='5px'>"
        // + alarmClockTime + "(" + beforeStr + ")" + "</font>";
        // 全天
        point = "<font color='" + colorState + "' size='5px'>"
                + context.getString(R.string.adapter_allday) + "</font>";
        // 顺延
        sequence = "<font color='" + colorState + "'>"
                + context.getString(R.string.adapter_shun) + "</font>";

        holder.timeall_tv_content.setText(mMap.get(ScheduleTable.schContent));
        if ("1".equals(isEnd)) {
            holder.timeall_tv_content.setTextColor(Color.parseColor(colorState));
            holder.timeall_tv_time.setTextColor(Color.parseColor(colorState));
            holder.bottom_month.setTextColor(Color.parseColor(colorState));
            holder.bottom_week.setTextColor(Color.parseColor(colorState));
            holder.timeall_tv_content.getPaint().setFlags(
                    Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
        } else {
            holder.timeall_tv_time.setTextColor(context.getResources().getColor(
                    R.color.mingtian_color));
            holder.bottom_month.setTextColor(context.getResources().getColor(
                    R.color.mingtian_color));
            holder.bottom_week.setTextColor(context.getResources().getColor(
                    R.color.mingtian_color));
            holder.timeall_tv_content.setTextColor(Color.BLACK);
            holder.timeall_tv_content.getPaint().setFlags(0 | Paint.ANTI_ALIAS_FLAG);
        }

        String openState = mMap.get(ScheduleTable.schOpenState);
        holder.personstate_tv.setVisibility(View.GONE);
        if (openState.equals("0")) {
            // personstate_tv.setText("私密");
            holder.personstate_tv.setText("");
        } else if (openState.equals("1")) {
            holder.personstate_tv.setText("公开");
        } else {
            // personstate_tv.setText("好友可见");
            holder.personstate_tv.setText("");
        }
        String nongli = "";
        if (mList.size() > 0) {
            if (DateUtil.parseDate(mMap.get(ScheduleTable.schDate)).before(
                    DateUtil.parseDate("2017-12-31"))) {
                nongli = App
                        .getDBcApplication()
                        .queryLunartoSolarList(mMap.get(ScheduleTable.schDate),
                                0).get("lunarCalendar");
            }
        }
        Calendar calendar1 = Calendar.getInstance();
        calendar1.setTime(DateUtil.parseDate(mMap.get(ScheduleTable.schDate)));

        Date dateToday = DateUtil.parseDateTime(DateUtil
                .formatDateTime(new Date()));
        long betweem = (long) (dateToday.getTime() - dateStr.getTime()) / 1000;
        long day = betweem / (24 * 3600);
        long hour = betweem % (24 * 3600) / 3600;
        long min = betweem % 3600 / 60;
        long afterday = ((long) (DateUtil.parseDate(
                DateUtil.formatDate(new Date())).getTime() - DateUtil
                .parseDate(key).getTime()) / 1000) / (24 * 3600);

        if (position == 0) {
            // 当position=0，判断今天中是否有待办日程，有就隐藏标题栏，隐藏顺和天后，如果今天没有日程，然后判断明天和之后的
            holder.timeall_ll.setVisibility(View.VISIBLE);
            if (today.substring(0, 10).equals(key)) {// &&
                holder.timeall_after.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setVisibility(View.VISIBLE);
                holder.outweek_ll.setVisibility(View.GONE);
                holder.outweekcount_tv.setVisibility(View.GONE);
                holder.bottom_month.setVisibility(View.GONE);
                holder.bottom_week.setVisibility(View.GONE);
                if ("0".equals(displayAlarm) && "1".equals(postpone)) {
                    holder.guoqi_img.setVisibility(View.GONE);
                    holder.timeall_ll.setVisibility(View.GONE);
                    holder.timeall_tv_shun.setVisibility(View.GONE);
                    holder.timeall_tv_lastday.setVisibility(View.GONE);
                    holder.bottom_month.setVisibility(View.GONE);
                    holder.bottom_week.setVisibility(View.GONE);
                    holder.timeall_tv_time.setText(context
                            .getString(R.string.adapter_untask));
                    holder.timeall_tv_time.setTextAppearance(context,
                            R.style.text_style_normal);
                    holder.timeall_tv_time.setTextColor(context.getResources()
                            .getColor(R.color.gongkai_txt));
                } else {
                    holder.timeall_ll.setVisibility(View.VISIBLE);
                    holder.timeall_tv_month.setVisibility(View.VISIBLE);
                    holder.timeall_tv_week.setVisibility(View.VISIBLE);
                    holder.timeall_tv_nongli.setVisibility(View.VISIBLE);
                    holder.timeall_tv_nongli.setText(nongli);
                    holder.bottom_month.setVisibility(View.GONE);
                    holder.bottom_week.setVisibility(View.GONE);
                    // timeall_tv_has.setVisibility(View.GONE);
                    holder.timeall_tv_daycount.setText(context
                            .getString(R.string.adapter_today));
                    holder.datebackground_ll
                            .setBackgroundResource(R.drawable.bg_todaytextview);

                    holder.timeall_tv_month.setText(ymd[1] + "-" + ymd[2]);
                    holder.timeall_tv_week.setText(CharacterUtil.getWeekOfDate(
                            context, DateUtil.parseDate(key)));
                    holder.timeall_tv_time.setTextAppearance(context,
                            R.style.text_style_bold);
                    if (!"".equals(localpath)) {
                        if ("0".equals(localpath)) {
                            holder.timeall_tv_week.setTextColor(Color
                                    .parseColor("#7F7F7F"));
                            holder.timeall_tv_nongli.setTextColor(Color
                                    .parseColor("#7F7F7F"));
                        } else {
                            holder.timeall_tv_week.setTextColor(Color.WHITE);
                            holder.timeall_tv_nongli.setTextColor(Color.WHITE);
                        }
                    } else {
                        holder.timeall_tv_week.setTextColor(context.getResources()
                                .getColor(R.color.white));
                        holder.timeall_tv_nongli.setTextColor(context.getResources()
                                .getColor(R.color.white));
                    }
                    if (Math.abs(hour) >= 1) {
                        holder.timeall_tv_lastday.setText(Math.abs(hour) + "小时后");
                    } else if (DateUtil.parseDateTimeHm(timeKey).getTime() > DateUtil
                            .parseDateTimeHm(
                                    DateUtil.formatDateTimeHm(new Date()))
                            .getTime()) {
                        if (Math.abs(min) == 0) {
                            holder.timeall_tv_lastday.setText("");
                        } else {
                            holder.timeall_tv_lastday.setText(Math.abs(min) + "分钟后");
                        }
                    }
                    if ("0".equals(displayAlarm)) {
                        holder.guoqi_img.setVisibility(View.GONE);
                        holder.timeall_tv_lastday.setVisibility(View.GONE);
                        if ("1".equals(mMap.get(ScheduleTable.schIsPostpone))) {
                            holder.timeall_tv_lastday.setVisibility(View.GONE);
                            holder.timeall_ll.setVisibility(View.GONE);
                            holder.timeall_tv_time.setText(context
                                    .getString(R.string.adapter_untask));
                            holder.timeall_tv_time.setTextAppearance(context,
                                    R.style.text_style_normal);
                            holder.timeall_tv_shun.setVisibility(View.GONE);
                            holder.timeall_tv_time.setTextColor(context.getResources()
                                    .getColor(R.color.gongkai_txt));
                        } else {
                            holder.timeall_tv_shun.setVisibility(View.GONE);
                            holder.timeall_tv_time.setText(Html.fromHtml(point));
                        }
                    } else {
                        if ("1".equals(mMap.get(ScheduleTable.schIsPostpone))) {
                            holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                            holder.timeall_tv_shun.setVisibility(View.VISIBLE);
                            holder.timeall_tv_shun
                                    .setBackgroundResource(shunBackKuang);
                            holder.timeall_tv_shun.setText(Html.fromHtml(sequence));
                        } else {
                            holder.timeall_tv_shun.setVisibility(View.GONE);
                            holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                        }
                        Date date1 = DateUtil.parseDateTime((DateUtil
                                .formatDateTime(new Date())));
                        if (dateStr.getTime() < date1.getTime()) {
                            if ("0".equals(displayAlarm)) {
                                if ("1".equals(isEnd)) {
                                    holder.guoqi_img.setVisibility(View.GONE);
                                } else {
                                    holder.guoqi_img.setVisibility(View.VISIBLE);
                                }
                                holder.guoqi_img.setVisibility(View.GONE);
                                holder.timeall_tv_lastday.setVisibility(View.GONE);
                            } else {
                                if ("1".equals(isEnd)) {
                                    holder.guoqi_img.setVisibility(View.GONE);
                                } else {
                                    holder.guoqi_img.setVisibility(View.VISIBLE);
                                }
                                holder.timeall_tv_lastday.setVisibility(View.GONE);
                            }
                        } else {
                            holder.guoqi_img.setVisibility(View.GONE);
                            if ("0".equals(displayAlarm)) {
                                holder.timeall_tv_lastday.setVisibility(View.GONE);
                            } else {
                                holder.timeall_tv_lastday.setVisibility(View.VISIBLE);
                            }
                        }
                    }

                }
            } else if (tomorrow.substring(0, 10).equals(key)) {
                holder.timeall_tv_time.setTextAppearance(context,
                        R.style.text_style_bold);
                holder.timeall_after.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setVisibility(View.VISIBLE);
                holder.outweek_ll.setVisibility(View.GONE);
                holder.outweekcount_tv.setVisibility(View.GONE);
                holder.guoqi_img.setVisibility(View.GONE);
                holder.timeall_tv_month.setVisibility(View.VISIBLE);
                holder.timeall_tv_week.setVisibility(View.VISIBLE);
                holder.timeall_tv_nongli.setVisibility(View.VISIBLE);
                holder.timeall_tv_nongli.setText(nongli);
                holder.bottom_month.setVisibility(View.GONE);
                holder.bottom_week.setVisibility(View.GONE);
                holder.timeall_ll.setVisibility(View.VISIBLE);
                // timeall_tv_has.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setText(context
                        .getString(R.string.adapter_tomorrow));
                holder.timeall_tv_month.setText(ymd[1] + "-" + ymd[2]);
                holder.timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"));
                holder.datebackground_ll
                        .setBackgroundResource(R.drawable.bg_tommorowtextview);
                holder.timeall_tv_week.setText(CharacterUtil.getWeekOfDate(context,
                        DateUtil.parseDate(key)));
                if (!"".equals(localpath)) {
                    if ("0".equals(localpath)) {
                        holder.timeall_tv_week.setTextColor(Color
                                .parseColor("#7F7F7F"));
                        holder.timeall_tv_nongli.setTextColor(Color
                                .parseColor("#7F7F7F"));
                    } else {
                        holder.timeall_tv_week.setTextColor(Color.WHITE);
                        holder.timeall_tv_nongli.setTextColor(Color.WHITE);
                    }
                } else {
                    holder.timeall_tv_week.setTextColor(context.getResources()
                            .getColor(R.color.white));
                    holder.timeall_tv_nongli.setTextColor(context.getResources()
                            .getColor(R.color.white));
                }
                if (Math.abs(day) >= 1) {
                    holder.timeall_tv_lastday.setText(Math.abs(day) + "天后");
                } else {
                    holder.timeall_tv_lastday.setText(Math.abs(hour) + "小时后");

                }
                if ("0".equals(displayAlarm)) {
                    holder.timeall_tv_lastday.setVisibility(View.GONE);
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_lastday.setVisibility(View.GONE);
                        holder.timeall_ll.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(context
                                .getString(R.string.adapter_untask));
                        holder.timeall_tv_time.setTextAppearance(context,
                                R.style.text_style_normal);
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setTextColor(context.getResources()
                                .getColor(R.color.gongkai_txt));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(point));
                    }
                } else {
                    holder.timeall_tv_lastday.setVisibility(View.VISIBLE);
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                        holder.timeall_tv_shun.setVisibility(View.VISIBLE);
                        holder.timeall_tv_shun.setBackgroundResource(shunBackKuang);
                        holder.timeall_tv_shun.setText(Html.fromHtml(sequence));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                    }
                }
            } else {
                holder.timeall_tv_time.setTextAppearance(context,
                        R.style.text_style_bold);
                holder.timeall_tv_lastday.setVisibility(View.GONE);
                holder.timeall_after.setVisibility(View.VISIBLE);
                holder.timeall_tv_daycount.setVisibility(View.GONE);
                holder.outweek_ll.setVisibility(View.GONE);
                holder.outweekcount_tv.setVisibility(View.GONE);
                holder.guoqi_img.setVisibility(View.GONE);
                holder.timeall_ll.setVisibility(View.VISIBLE);
                holder.timeall_tv_month.setVisibility(View.VISIBLE);
                holder.timeall_tv_week.setVisibility(View.VISIBLE);
                holder.timeall_tv_nongli.setVisibility(View.VISIBLE);
                holder.bottom_month.setVisibility(View.GONE);
                holder.bottom_week.setVisibility(View.GONE);

                holder.timeall_tv_daycount.setText(context
                        .getString(R.string.adapter_outweek));
                holder.timeall_tv_month.setText(ymd[1] + "-" + ymd[2]);
                holder.timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"));
                holder.datebackground_ll
                        .setBackgroundResource(R.drawable.bg_tommorowtextview);
                holder.timeall_tv_week.setText(CharacterUtil.getWeekOfDate(context,
                        DateUtil.parseDate(key)));
                if (!"".equals(localpath)) {
                    if ("0".equals(localpath)) {
                        holder.timeall_after.setTextColor(Color.parseColor("#7F7F7F"));
                        holder.timeall_tv_nongli.setTextColor(Color
                                .parseColor("#7F7F7F"));
                        holder.timeall_tv_week.setTextColor(Color
                                .parseColor("#7F7F7F"));
                    } else {
                        holder.timeall_tv_nongli.setTextColor(Color.WHITE);
                        holder.timeall_after.setTextColor(Color.WHITE);
                        holder.timeall_tv_week.setTextColor(context.getResources()
                                .getColor(R.color.white));
                    }
                } else {
                    holder.timeall_after.setTextColor(Color.WHITE);
                    holder.timeall_tv_nongli.setTextColor(Color.WHITE);
                    holder.timeall_tv_week.setTextColor(context.getResources()
                            .getColor(R.color.white));
                }
                holder.timeall_after.setText(Math.abs(afterday) + "天后");
                if ("0".equals(displayAlarm)) {
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_lastday.setVisibility(View.GONE);
                        holder.timeall_ll.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(context
                                .getString(R.string.adapter_untask));
                        holder.timeall_tv_time.setTextAppearance(context,
                                R.style.text_style_normal);
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setTextColor(context.getResources()
                                .getColor(R.color.gongkai_txt));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(point));
                    }
                } else {
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                        holder.timeall_tv_shun.setVisibility(View.VISIBLE);
                        holder.timeall_tv_shun.setBackgroundResource(shunBackKuang);
                        holder.timeall_tv_shun.setText(Html.fromHtml(sequence));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                    }
                }
            }
        } else if (mList.get(position).get(ScheduleTable.schDate)
                .equals(mList.get(position - 1).get(ScheduleTable.schDate))) {
            // 判断当前日期是否为今天，如果是今天，就得区分待办和今天日程
            // 如果不为今天，就按找平时日程处理
            if (today.substring(0, 10).equals(
                    mList.get(position).get(ScheduleTable.schDate))) {
                holder.timeall_after.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setVisibility(View.VISIBLE);
                holder.outweek_ll.setVisibility(View.GONE);
                holder.outweekcount_tv.setVisibility(View.GONE);
                holder.bottom_month.setVisibility(View.GONE);
                holder.bottom_week.setVisibility(View.GONE);
                if ("0".equals(displayAlarm) && "1".equals(postpone)) {// &&
                    holder.guoqi_img.setVisibility(View.GONE);
                    holder.timeall_ll.setVisibility(View.GONE);
                    holder.timeall_tv_lastday.setVisibility(View.GONE);
                    holder.timeall_tv_time.setText(context
                            .getString(R.string.adapter_untask));
                    holder.timeall_tv_time.setTextAppearance(context,
                            R.style.text_style_normal);
                    holder.timeall_tv_shun.setVisibility(View.GONE);
                    // timeall_tv_has.setVisibility(View.GONE);
                    holder.timeall_tv_time.setTextColor(context.getResources()
                            .getColor(R.color.gongkai_txt));
                } else {
                    if (position == uncount) {
                        holder.timeall_ll.setVisibility(View.VISIBLE);
                    } else {
                        holder.timeall_ll.setVisibility(View.GONE);
                    }
                    holder.timeall_tv_time.setTextAppearance(context,
                            R.style.text_style_bold);
                    holder.timeall_tv_month.setVisibility(View.VISIBLE);
                    holder.timeall_tv_week.setVisibility(View.VISIBLE);
                    holder.timeall_tv_nongli.setVisibility(View.VISIBLE);
                    holder.timeall_tv_nongli.setText(nongli);
                    holder.timeall_tv_daycount.setText(context.getResources()
                            .getString(R.string.adapter_today));
                    holder.timeall_tv_daycount.setTextColor(Color
                            .parseColor("#ffffff"));
                    holder.datebackground_ll
                            .setBackgroundResource(R.drawable.bg_todaytextview);
                    holder.timeall_tv_month.setText(ymd[1] + "-" + ymd[2]);
                    holder.timeall_tv_week.setText(CharacterUtil.getWeekOfDate(
                            context, DateUtil.parseDate(key)));
                    if (!"".equals(localpath)) {
                        if ("0".equals(localpath)) {
                            holder.timeall_tv_week.setTextColor(Color
                                    .parseColor("#7F7F7F"));
                            holder.timeall_tv_nongli.setTextColor(Color
                                    .parseColor("#7F7F7F"));
                        } else {
                            holder.timeall_tv_week.setTextColor(Color.WHITE);
                            holder.timeall_tv_nongli.setTextColor(Color.WHITE);
                        }
                    } else {
                        holder.timeall_tv_week.setTextColor(context.getResources()
                                .getColor(R.color.white));
                        holder.timeall_tv_nongli.setTextColor(context.getResources()
                                .getColor(R.color.white));
                    }
                    if (Math.abs(hour) >= 1) {
                        holder.timeall_tv_lastday.setText(Math.abs(hour) + "小时后");
                    } else if (DateUtil.parseDateTimeHm(timeKey).getTime() > DateUtil
                            .parseDateTimeHm(
                                    DateUtil.formatDateTimeHm(new Date()))
                            .getTime()) {
                        if (Math.abs(min) == 0) {
                            holder.timeall_tv_lastday.setText("");
                        } else {
                            holder.timeall_tv_lastday.setText(Math.abs(min) + "分钟后");
                        }
                    } else {
                        if (Math.abs(min) == 0) {
                            holder.timeall_tv_lastday.setText("");
                        } else {
                            holder.timeall_tv_lastday.setText(Math.abs(min) + "分钟前");
                        }
                    }
                    if ("0".equals(displayAlarm)) {
                        holder.timeall_tv_lastday.setVisibility(View.GONE);
                        holder.guoqi_img.setVisibility(View.GONE);
                        if ("1".equals(mMap.get(ScheduleTable.schIsPostpone))) {
                            holder.timeall_tv_lastday.setVisibility(View.GONE);
                            holder.timeall_ll.setVisibility(View.GONE);
                            holder.timeall_tv_time.setText(context
                                    .getString(R.string.adapter_untask));
                            holder.timeall_tv_time.setTextAppearance(context,
                                    R.style.text_style_normal);
                            holder.timeall_tv_shun.setVisibility(View.GONE);
                            holder.timeall_tv_time.setTextColor(context.getResources()
                                    .getColor(R.color.gongkai_txt));
                        } else {
                            holder.timeall_tv_shun.setVisibility(View.GONE);
                            holder.timeall_tv_time.setText(Html.fromHtml(point));
                        }
                    } else {
                        if ("1".equals(mMap.get(ScheduleTable.schIsPostpone))) {
                            holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                            holder.timeall_tv_shun.setVisibility(View.VISIBLE);
                            holder.timeall_tv_shun
                                    .setBackgroundResource(shunBackKuang);
                            holder.timeall_tv_shun.setText(Html.fromHtml(sequence));
                        } else {
                            holder.timeall_tv_shun.setVisibility(View.GONE);
                            holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                        }
                        Date date1 = DateUtil.parseDateTime((DateUtil
                                .formatDateTime(new Date())));
                        if (dateStr.getTime() < date1.getTime()) {
                            if ("1".equals(isEnd)) {
                                holder.guoqi_img.setVisibility(View.GONE);
                            } else {
                                holder.guoqi_img.setVisibility(View.VISIBLE);
                            }
                            holder.timeall_tv_lastday.setVisibility(View.GONE);

                        } else {
                            holder.guoqi_img.setVisibility(View.GONE);
                            holder.timeall_tv_lastday.setVisibility(View.VISIBLE);
                        }
                    }
                }
            } else if (tomorrow.substring(0, 10).equals(
                    mMap.get(ScheduleTable.schDate))) {
                holder.timeall_tv_time.setTextAppearance(context,
                        R.style.text_style_bold);
                holder.timeall_after.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setVisibility(View.VISIBLE);
                holder.outweek_ll.setVisibility(View.GONE);
                holder.outweekcount_tv.setVisibility(View.GONE);
                holder.guoqi_img.setVisibility(View.GONE);
                holder.timeall_ll.setVisibility(View.GONE);
                holder.bottom_month.setVisibility(View.GONE);
                holder.bottom_week.setVisibility(View.GONE);
                if (Math.abs(day) >= 1) {
                    holder.timeall_tv_lastday.setText(Math.abs(day) + "天后");
                } else {
                    holder.timeall_tv_lastday.setText(Math.abs(hour) + "小时后");

                }
                if ("0".equals(displayAlarm)) {
                    holder.timeall_tv_lastday.setVisibility(View.GONE);
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_lastday.setVisibility(View.GONE);
                        holder.timeall_ll.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(context
                                .getString(R.string.adapter_untask));
                        holder.timeall_tv_time.setTextAppearance(context,
                                R.style.text_style_normal);
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setTextColor(context.getResources()
                                .getColor(R.color.gongkai_txt));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(point));
                    }
                } else {
                    holder.timeall_tv_lastday.setVisibility(View.VISIBLE);
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                        holder.timeall_tv_shun.setVisibility(View.VISIBLE);
                        holder.timeall_tv_shun.setBackgroundResource(shunBackKuang);
                        holder.timeall_tv_shun.setText(Html.fromHtml(sequence));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                    }
                }
            } else {

                holder.timeall_tv_time.setTextAppearance(context,
                        R.style.text_style_bold);
                holder.timeall_after.setVisibility(View.GONE);
                holder.timeall_tv_lastday.setVisibility(View.GONE);
                holder.outweek_ll.setVisibility(View.GONE);
                holder.outweekcount_tv.setVisibility(View.GONE);
                if (mList
                        .get(position)
                        .get(ScheduleTable.schDate)
                        .equals(mList.get(position - 1).get(
                                ScheduleTable.schDate))) {
                    holder.timeall_ll.setVisibility(View.GONE);
                    holder.timeall_tv_month.setVisibility(View.GONE);
                    holder.timeall_tv_week.setVisibility(View.GONE);
                    holder.timeall_tv_nongli.setVisibility(View.GONE);
                } else {
                    holder.timeall_ll.setVisibility(View.VISIBLE);
                    holder.timeall_tv_month.setVisibility(View.VISIBLE);
                    holder.timeall_tv_week.setVisibility(View.VISIBLE);
                    holder.timeall_tv_nongli.setVisibility(View.VISIBLE);
                }
                holder.guoqi_img.setVisibility(View.GONE);
                holder.bottom_month.setVisibility(View.GONE);
                holder.bottom_week.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setVisibility(View.GONE);
                holder.timeall_tv_nongli.setText(nongli);

                holder.timeall_tv_daycount.setText(context
                        .getString(R.string.adapter_outweek));
                holder.timeall_tv_month.setText(ymd[1] + "-" + ymd[2]);
                holder.timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"));
                holder.datebackground_ll
                        .setBackgroundResource(R.drawable.bg_tommorowtextview);
                holder.timeall_tv_week.setText(CharacterUtil.getWeekOfDate(context,
                        DateUtil.parseDate(key)));
                if (!"".equals(localpath)) {
                    if ("0".equals(localpath)) {
                        holder.bottom_week.setTextColor(Color.parseColor("#7F7F7F"));
                    } else {
                        holder.bottom_week.setTextColor(context.getResources()
                                .getColor(R.color.mingtian_color));
                    }
                } else {
                    if ("1".equals(isEnd)) {
                        holder.bottom_week.setTextColor(Color.parseColor("#7F7F7F"));
                    } else {
                        holder.bottom_week.setTextColor(context.getResources()
                                .getColor(R.color.mingtian_color));
                    }
                }
                holder.timeall_after.setText(Math.abs(afterday) + "天后");
                if ("0".equals(displayAlarm)) {
                    if ("1".equals(mMap.get(ScheduleTable.schIsPostpone))) {
                        holder.timeall_tv_lastday.setVisibility(View.GONE);
                        holder.timeall_ll.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(context
                                .getString(R.string.adapter_untask));
                        holder.timeall_tv_time.setTextAppearance(context,
                                R.style.text_style_normal);
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setTextColor(context.getResources()
                                .getColor(R.color.gongkai_txt));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(point));
                    }
                } else {
                    if ("1".equals(mMap.get(ScheduleTable.schIsPostpone))) {
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                        holder.timeall_tv_shun.setVisibility(View.VISIBLE);
                        holder.timeall_tv_shun.setBackgroundResource(shunBackKuang);
                        holder.timeall_tv_shun.setText(Html.fromHtml(sequence));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                    }
                }
                // }
            }
        } else {
            if (today.substring(0, 10).toString().equals(key)) {// 今天
                holder.timeall_after.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setVisibility(View.VISIBLE);
                holder.outweek_ll.setVisibility(View.GONE);
                holder.outweekcount_tv.setVisibility(View.GONE);
                holder.bottom_month.setVisibility(View.GONE);
                holder.bottom_week.setVisibility(View.GONE);
                if ("0".equals(displayAlarm) && "1".equals(postpone)) {
                    holder.timeall_tv_lastday.setVisibility(View.GONE);
                    holder.timeall_ll.setVisibility(View.GONE);
                    holder.timeall_tv_time.setText(context
                            .getString(R.string.adapter_untask));
                    holder.timeall_tv_time.setTextAppearance(context,
                            R.style.text_style_normal);
                    holder.timeall_tv_time.setTextColor(context.getResources()
                            .getColor(R.color.gongkai_txt));
                    holder.timeall_tv_shun.setVisibility(View.GONE);
                } else {
                    holder.timeall_tv_time.setTextAppearance(context,
                            R.style.text_style_bold);
                    holder.timeall_ll.setVisibility(View.VISIBLE);
                    holder.timeall_tv_nongli.setText(nongli);
                    holder.timeall_tv_daycount.setText(context
                            .getString(R.string.adapter_today));
                    holder.timeall_tv_daycount.setTextColor(Color
                            .parseColor("#ffffff"));
                    holder.datebackground_ll
                            .setBackgroundResource(R.drawable.bg_todaytextview);
                    holder.timeall_tv_month.setText(ymd[1] + "-" + ymd[2]);
                    holder.timeall_tv_week.setText(CharacterUtil.getWeekOfDate(
                            context, DateUtil.parseDate(key)));
                    if (!"".equals(localpath)) {
                        if ("0".equals(localpath)) {
                            holder.timeall_tv_week.setTextColor(Color
                                    .parseColor("#7F7F7F"));
                            holder.timeall_tv_nongli.setTextColor(Color
                                    .parseColor("#7F7F7F"));
                        } else {
                            holder.timeall_tv_week.setTextColor(Color.WHITE);
                            holder.timeall_tv_nongli.setTextColor(Color.WHITE);
                        }
                    } else {
                        holder.timeall_tv_week.setTextColor(context.getResources()
                                .getColor(R.color.white));
                        holder.timeall_tv_nongli.setTextColor(context.getResources()
                                .getColor(R.color.white));
                    }
                    if (Math.abs(hour) >= 1) {
                        holder.timeall_tv_lastday.setText(Math.abs(hour) + "小时后");
                    } else if (DateUtil.parseDateTimeHm(timeKey).getTime() > DateUtil
                            .parseDateTimeHm(
                                    DateUtil.formatDateTimeHm(new Date()))
                            .getTime()) {
                        if (Math.abs(min) == 0) {
                            holder.timeall_tv_lastday.setText("");
                        } else {
                            holder.timeall_tv_lastday.setText(Math.abs(min) + "分钟后");
                        }
                    } else {
                        if (Math.abs(min) == 0) {
                            holder.timeall_tv_lastday.setText("");
                        } else {
                            holder.timeall_tv_lastday.setText(Math.abs(min) + "分钟前");
                        }
                    }
                    if ("0".equals(displayAlarm)) {
                        holder.timeall_tv_lastday.setVisibility(View.GONE);
                        if ("1".equals(mMap.get(ScheduleTable.schIsPostpone))) {
                            holder.timeall_tv_lastday.setVisibility(View.GONE);
                            holder.timeall_ll.setVisibility(View.GONE);
                            holder.timeall_tv_time.setText(context
                                    .getString(R.string.adapter_untask));
                            holder.timeall_tv_time.setTextAppearance(context,
                                    R.style.text_style_normal);
                            holder.timeall_tv_shun.setVisibility(View.GONE);

                            holder.timeall_tv_time.setTextColor(context.getResources()
                                    .getColor(R.color.gongkai_txt));

                        } else {
                            holder.timeall_tv_shun.setVisibility(View.GONE);
                            holder.timeall_tv_time.setText(Html.fromHtml(point));
                        }
                    } else {
                        if ("1".equals(mMap.get(ScheduleTable.schIsPostpone))) {
                            holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                            holder.timeall_tv_shun.setVisibility(View.VISIBLE);
                            holder.timeall_tv_shun
                                    .setBackgroundResource(shunBackKuang);
                            holder.timeall_tv_shun.setText(Html.fromHtml(sequence));
                        } else {
                            holder.timeall_tv_shun.setVisibility(View.GONE);
                            holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                        }
                        Date date1 = DateUtil.parseDateTime((DateUtil
                                .formatDateTime(new Date())));
                        if (dateStr.getTime() < date1.getTime()) {
                            holder.timeall_tv_lastday.setVisibility(View.GONE);
                            if ("1".equals(isEnd)) {
                                holder.guoqi_img.setVisibility(View.GONE);
                            } else {
                                holder.guoqi_img.setVisibility(View.VISIBLE);
                            }
                        } else {
                            holder.timeall_tv_lastday.setVisibility(View.VISIBLE);
                            holder.guoqi_img.setVisibility(View.GONE);
                        }
                    }
                }
            } else if (tomorrow.substring(0, 10).toString().equals(key)) {// 明天
                holder.timeall_tv_time.setTextAppearance(context,
                        R.style.text_style_bold);
                holder.timeall_tv_month.setVisibility(View.VISIBLE);
                holder.timeall_tv_week.setVisibility(View.VISIBLE);
                holder.timeall_tv_nongli.setVisibility(View.VISIBLE);
                holder.timeall_after.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setVisibility(View.VISIBLE);
                holder.outweek_ll.setVisibility(View.GONE);
                holder.outweekcount_tv.setVisibility(View.GONE);
                holder.bottom_month.setVisibility(View.GONE);
                holder.bottom_week.setVisibility(View.GONE);
                holder.guoqi_img.setVisibility(View.GONE);
                holder.timeall_ll.setVisibility(View.VISIBLE);
                holder.timeall_tv_nongli.setText(nongli);
                holder.timeall_tv_daycount.setText(context
                        .getString(R.string.adapter_tomorrow));
                holder.timeall_tv_month.setText(ymd[1] + "-" + ymd[2]);
                holder.timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"));
                holder.datebackground_ll
                        .setBackgroundResource(R.drawable.bg_tommorowtextview);
                holder.timeall_tv_week.setText(CharacterUtil.getWeekOfDate(context,
                        DateUtil.parseDate(key)));
                if (!"".equals(localpath)) {
                    if ("0".equals(localpath)) {
                        holder.timeall_tv_nongli.setTextColor(Color
                                .parseColor("#7F7F7F"));
                        holder.timeall_tv_week.setTextColor(Color
                                .parseColor("#7F7F7F"));
                    } else {
                        holder.timeall_tv_week.setTextColor(Color.WHITE);
                        holder.timeall_tv_nongli.setTextColor(Color.WHITE);
                    }
                } else {
                    holder.timeall_tv_nongli.setTextColor(context.getResources()
                            .getColor(R.color.white));
                    holder.timeall_tv_week.setTextColor(context.getResources()
                            .getColor(R.color.white));
                }
                if (Math.abs(day) >= 1) {
                    holder.timeall_tv_lastday.setText(Math.abs(day) + "天后");
                } else {
                    holder.timeall_tv_lastday.setText(Math.abs(hour) + "小时后");

                }
                if ("0".equals(displayAlarm)) {
                    holder.timeall_tv_lastday.setVisibility(View.GONE);
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_lastday.setVisibility(View.GONE);
                        holder.timeall_ll.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(context
                                .getString(R.string.adapter_untask));
                        holder.timeall_tv_time.setTextAppearance(context,
                                R.style.text_style_normal);
                        holder.timeall_tv_shun.setVisibility(View.GONE);

                        holder.timeall_tv_time.setTextColor(context.getResources()
                                .getColor(R.color.gongkai_txt));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(point));
                    }
                } else {
                    holder.timeall_tv_lastday.setVisibility(View.VISIBLE);
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                        holder.timeall_tv_shun.setVisibility(View.VISIBLE);
                        holder.timeall_tv_shun.setBackgroundResource(shunBackKuang);
                        holder.timeall_tv_shun.setText(Html.fromHtml(sequence));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                    }
                }
            } else {
                holder.timeall_tv_time.setTextAppearance(context,
                        R.style.text_style_bold);
                holder.timeall_tv_lastday.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setVisibility(View.GONE);

                if (mList
                        .get(position)
                        .get(ScheduleTable.schDate)
                        .equals(mList.get(position - 1).get(
                                ScheduleTable.schDate))) {
                    holder.timeall_ll.setVisibility(View.GONE);
                    holder.timeall_after.setVisibility(View.GONE);
                    holder.timeall_tv_month.setVisibility(View.GONE);
                    holder.timeall_tv_week.setVisibility(View.GONE);
                    holder.timeall_tv_nongli.setVisibility(View.GONE);
                } else {
                    holder.timeall_ll.setVisibility(View.VISIBLE);
                    holder.timeall_after.setVisibility(View.VISIBLE);
                    holder.timeall_tv_month.setVisibility(View.VISIBLE);
                    holder.timeall_tv_week.setVisibility(View.VISIBLE);
                    holder.timeall_tv_nongli.setVisibility(View.VISIBLE);
                }
                // }
                holder.timeall_tv_nongli.setText(nongli);
                holder.guoqi_img.setVisibility(View.GONE);
                holder.bottom_month.setVisibility(View.GONE);
                holder.bottom_week.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setVisibility(View.GONE);
                holder.timeall_tv_daycount.setText(context
                        .getString(R.string.adapter_outweek));
                holder.timeall_tv_month.setText(ymd[1] + "-" + ymd[2]);
                holder.timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"));
                holder.datebackground_ll
                        .setBackgroundResource(R.drawable.bg_tommorowtextview);
                holder.timeall_tv_week.setText(CharacterUtil.getWeekOfDate(context,
                        DateUtil.parseDate(key)));
                if (!"".equals(localpath)) {
                    if ("0".equals(localpath)) {
                        holder.timeall_tv_week.setTextColor(Color
                                .parseColor("#7F7F7F"));
                        holder.timeall_tv_nongli.setTextColor(Color
                                .parseColor("#7F7F7F"));
                        if ("1".equals(isEnd)) {
                            holder.bottom_week.setTextColor(Color
                                    .parseColor("#7F7F7F"));
                        } else {
                            holder.bottom_week.setTextColor(context.getResources()
                                    .getColor(R.color.mingtian_color));
                        }
                    } else {
                        holder.timeall_tv_week.setTextColor(Color.WHITE);
                        holder.timeall_tv_nongli.setTextColor(Color.WHITE);
                        if ("1".equals(isEnd)) {
                            holder.bottom_week.setTextColor(Color
                                    .parseColor("#7F7F7F"));
                        } else {
                            holder.bottom_week.setTextColor(context.getResources()
                                    .getColor(R.color.mingtian_color));
                        }
                    }
                } else {
                    holder.timeall_tv_week.setTextColor(Color.WHITE);
                    holder.timeall_tv_nongli.setTextColor(Color.WHITE);
                    if ("1".equals(isEnd)) {
                        holder.bottom_week.setTextColor(Color.parseColor("#7F7F7F"));
                    } else {
                        holder.bottom_week.setTextColor(context.getResources()
                                .getColor(R.color.mingtian_color));
                    }
                }
                if (Math.abs(day) >= 1) {
                    holder.timeall_after.setText(Math.abs(afterday) + "天后");
                } else {
                    holder.timeall_after.setText(Math.abs(hour) + "小时后");

                }
                if ("0".equals(displayAlarm)) {
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_lastday.setVisibility(View.GONE);
                        holder.timeall_ll.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(context
                                .getString(R.string.adapter_untask));
                        holder.timeall_tv_time.setTextAppearance(context,
                                R.style.text_style_normal);
                        holder.timeall_tv_shun.setVisibility(View.GONE);

                        holder.timeall_tv_time.setTextColor(context.getResources()
                                .getColor(R.color.gongkai_txt));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(point));
                    }
                } else {
                    if ("1".equals(postpone)) {
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                        holder.timeall_tv_shun.setVisibility(View.VISIBLE);
                        holder.timeall_tv_shun.setBackgroundResource(shunBackKuang);
                        holder.timeall_tv_shun.setText(Html.fromHtml(sequence));
                    } else {
                        holder.timeall_tv_shun.setVisibility(View.GONE);
                        holder.timeall_tv_time.setText(Html.fromHtml(clockTime));
                    }
                }
            }
        }
        // if (position != 0) {
        if (uncount == 0 && todaycount == 0 && tomorrowcount == 0
                && inweekcount == 0) {
            holder.outweek_ll.setVisibility(View.GONE);
            holder.outweekcount_tv.setVisibility(View.GONE);
        } else {
            if (position == uncount + todaycount + tomorrowcount + inweekcount - 1) {
                if ("1".equals(outweekfag)) {
                    holder.outweek_ll.setVisibility(View.GONE);
                    holder.outweekcount_tv.setVisibility(View.GONE);
                } else {
                    if (outweekcount == 0) {
                        holder.outweek_ll.setVisibility(View.GONE);
                        holder.outweekcount_tv.setVisibility(View.GONE);
                    } else {
//                        int b = uncount + todaycount + tomorrowcount + inweekcount - 1;
//                        Log.e("TAG","myscheduleadaoter--position="+position+",index="+b+",uncount="+uncount
//                                +",todaycount="+todaycount+",tomorrowcount="+tomorrowcount+",inweekcount="+inweekcount);
                        holder.outweek_ll.setVisibility(View.VISIBLE);
                        holder.outweekcount_tv.setVisibility(View.VISIBLE);
                        holder.outweekcount_tv.setText("一周后(" + outweekcount + ")");
                    }
                }
            } else {
                if ("1".equals(outweekfag)) {
                    holder.outweek_ll.setVisibility(View.GONE);
                    holder.outweekcount_tv.setVisibility(View.GONE);
                }
            }
        }
        // }
        // 设置时间距离前一个的距离
        LinearLayout.LayoutParams timeparams = new LinearLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        if (holder.bottom_month.getVisibility() == View.VISIBLE) {
            timeparams.setMargins(Utils.dipTopx(context, 5), 0, 0, 0);
            holder.timeall_tv_time.setLayoutParams(timeparams);
        }
        // 设置右边删除
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        // 设置下面布局
        LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        // 设置距离顶部距离
        LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

        if (holder.timeall_ll.getVisibility() == View.VISIBLE) {
            if (uncount == 0) {

                params2.setMargins(0,
                        Utils.dipTopx(context, 16), 0,
                        0);
                holder.top_ll.setLayoutParams(params2);

            } else {
                params2.setMargins(0,
                        Utils.dipTopx(context, 30), 0,
                        0);
                holder.top_ll.setLayoutParams(params2);
            }
        } else {
            params2.setMargins(0, Utils.dipTopx(context, 3), 0, 0);
            holder.top_ll.setLayoutParams(params2);
        }

//		swipeLayout.setLayoutParams(params1);

        if ("1".equals(isEnd)) {
            holder.select_cb.setChecked(true);
            if ("1".equals(mMap.get(ScheduleTable.schIsImportant))) {
                holder.timeall_rela_right.setBackground(context.getResources()
                        .getDrawable(R.drawable.bg_sch_important_end));
            } else {
                holder.timeall_rela_right.setBackground(context.getResources()
                        .getDrawable(R.drawable.bg_sch_end));
            }
            holder.comename_tv.setTextColor(context.getResources().getColor(
                    R.color.gongkai_txt));
            if (!"0".equals(StringUtils.getIsStringEqulesNull(mMap
                    .get(ScheduleTable.schcRecommendId)))) {
                if (!"".equals(StringUtils.getIsStringEqulesNull(mMap
                        .get(ScheduleTable.schcRecommendName)))) {
                    boolean new_type = false;
                    for (int i = 0; i < listBeanList.size(); i++) {
                        String cid = listBeanList.get(i).getCId().trim();
                        String schid = mList.get(position).get(ScheduleTable.schID).trim();
                        if (cid.equals(schid) && listBeanList.get(i).getCount() == 1) {
                            new_type = true;
                            break;
                        }
                    }
                    holder.new_img.setBackground(context.getResources().getDrawable(R.mipmap.icon_diandian));
                    holder.new_img.setVisibility(new_type == true ? View.VISIBLE : View.GONE);
                    holder.timeall_tv_lastday.setVisibility(View.GONE);
                    String co = "@" + mMap.get(ScheduleTable.schcRecommendName) + ":";
                    String cb = co + mMap.get(ScheduleTable.schContent);
                    SpannableStringBuilder style = new SpannableStringBuilder(cb);
                    style.setSpan(new ForegroundColorSpan(context.getResources().getColor(R.color.gongkai_txt)), 0, co.length(),
                            Spannable.SPAN_EXCLUSIVE_INCLUSIVE); //设置指定位置文字的颜色
                    holder.timeall_tv_content.setText(style);
                    holder.comename_tv.setVisibility(View.GONE);

                } else {
                    if (!"0".equals(mMap.get(ScheduleTable.schRepeatID))) {
                        String type = App
                                .getDBcApplication()
                                .queryRepateType(
                                        mMap.get(ScheduleTable.schRepeatID))
                                .get("type");
                        if ("0".equals(mMap.get(ScheduleTable.schRepeatLink))) {
                            holder.comename_tv.setVisibility(View.GONE);
                        } else {
                            holder.comename_tv.setVisibility(View.VISIBLE);
                            holder.new_img.setVisibility(View.GONE);
                        }
                        holder.comename_tv.setTextColor(context.getResources()
                                .getColor(R.color.gongkai_txt));
                        if ("1".equals(type)) {
                            holder.comename_tv.setText("每天重复");
                        } else if ("2".equals(type)) {
                            holder.comename_tv.setText("每周重复");
                        } else if ("3".equals(type)) {
                            holder.comename_tv.setText("每月重复");
                        } else if ("4".equals(type) || "6".equals(type)) {
                            holder.comename_tv.setText("每年重复");
                        } else {
                            holder.comename_tv.setText("工作日重复");
                        }
                    } else {
                        holder.comename_tv.setVisibility(View.GONE);
                    }
                }
            } else if (!"0".equals(mMap.get(ScheduleTable.schRepeatID))) {
                String type = App.getDBcApplication()
                        .queryRepateType(mMap.get(ScheduleTable.schRepeatID))
                        .get("type");
                if ("0".equals(mMap.get(ScheduleTable.schRepeatLink))) {
                    holder.comename_tv.setVisibility(View.GONE);
                } else {
                    holder.comename_tv.setVisibility(View.VISIBLE);
                    holder.new_img.setVisibility(View.GONE);
                }
                if ("1".equals(type)) {
                    holder.comename_tv.setText("每天重复");
                } else if ("2".equals(type)) {
                    holder.comename_tv.setText("每周重复");
                } else if ("3".equals(type)) {
                    holder.comename_tv.setText("每月重复");
                } else if ("4".equals(type) || "6".equals(type)) {
                    holder.comename_tv.setText("每年重复");
                } else {
                    holder.comename_tv.setText("工作日重复");
                }
            }
        } else {
            if ("1".equals(important)) {
                holder.timeall_rela_right.setBackground(context.getResources()
                        .getDrawable(R.drawable.bg_sch_important));
            } else {
                holder.timeall_rela_right.setBackground(context.getResources()
                        .getDrawable(R.drawable.bg_sch_normal));
            }
            holder.select_cb.setChecked(false);

            if (!"0".equals(StringUtils.getIsStringEqulesNull(mMap
                    .get(ScheduleTable.schcRecommendId)))) {
                if (!"".equals(StringUtils.getIsStringEqulesNull(mMap
                        .get(ScheduleTable.schcRecommendName)))) {
                    boolean new_type = false;
                    for (int i = 0; i < listBeanList.size(); i++) {
                        String cid = listBeanList.get(i).getCId().trim();
                        String schid = mList.get(position).get(ScheduleTable.schID).trim();
                        if (cid.equals(schid) && listBeanList.get(i).getCount() == 1) {
                            new_type = true;
                            break;
                        }
                    }
                    holder.new_img.setBackground(context.getResources().getDrawable(R.mipmap.icon_diandian));
                    holder.new_img.setVisibility(new_type == true ? View.VISIBLE : View.GONE);
                    holder.timeall_tv_lastday.setVisibility(View.GONE);
                    String co = "@" + mMap.get(ScheduleTable.schcRecommendName) + ":";
                    String cb = co + mMap.get(ScheduleTable.schContent);
                    SpannableStringBuilder style = new SpannableStringBuilder(cb);
                    style.setSpan(new ForegroundColorSpan(context.getResources().getColor(R.color.mingtian_color)), 0, co.length(),
                            Spannable.SPAN_EXCLUSIVE_INCLUSIVE); //设置指定位置文字的颜色
                    holder.timeall_tv_content.setText(style);
                    holder.comename_tv.setVisibility(View.GONE);

                    if ("1".equals(isEnd)) {
                        holder.timeall_tv_content.setTextColor(context.getResources().getColor(R.color.gongkai_txt));
                    }

                } else {
                    if (!"0".equals(mMap.get(ScheduleTable.schRepeatID))) {
                        String type = App
                                .getDBcApplication()
                                .queryRepateType(
                                        mMap.get(ScheduleTable.schRepeatID))
                                .get("type");
                        if ("0".equals(mMap.get(ScheduleTable.schRepeatLink))) {
                            holder.comename_tv.setVisibility(View.GONE);
                        } else {
                            holder.comename_tv.setVisibility(View.VISIBLE);
                            holder.new_img.setVisibility(View.GONE);
                        }
                        holder.comename_tv.setTextColor(context.getResources()
                                .getColor(R.color.gongkai_txt));
                        if ("1".equals(type)) {
                            holder.comename_tv.setText("每天重复");
                        } else if ("2".equals(type)) {
                            holder.comename_tv.setText("每周重复");
                        } else if ("3".equals(type)) {
                            holder.comename_tv.setText("每月重复");
                        } else if ("4".equals(type) || "6".equals(type)) {
                            holder.comename_tv.setText("每年重复");
                        } else {
                            holder.comename_tv.setText("工作日重复");
                        }
                    } else {
                        holder.comename_tv.setVisibility(View.GONE);
                    }
                }
            } else {
                if (!"0".equals(mMap.get(ScheduleTable.schRepeatID))) {
                    String type = App
                            .getDBcApplication()
                            .queryRepateType(
                                    mMap.get(ScheduleTable.schRepeatID))
                            .get("type");
                    if ("0".equals(mMap.get(ScheduleTable.schRepeatLink))) {
                        holder.comename_tv.setVisibility(View.GONE);
                    } else {
                        holder.comename_tv.setVisibility(View.VISIBLE);
                        holder.new_img.setVisibility(View.GONE);
                    }
                    holder.comename_tv.setTextColor(context.getResources().getColor(
                            R.color.gongkai_txt));
                    if ("1".equals(type)) {
                        holder.comename_tv.setText("每天重复");
                    } else if ("2".equals(type)) {
                        holder.comename_tv.setText("每周重复");
                    } else if ("3".equals(type)) {
                        holder.comename_tv.setText("每月重复");
                    } else if ("4".equals(type) || "6".equals(type)) {
                        holder.comename_tv.setText("每年重复");
                    } else {
                        holder.comename_tv.setText("工作日重复");
                    }
                    if ("1".equals(important)) {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_important));
                    } else {
                        holder.timeall_rela_right.setBackground(context.getResources()
                                .getDrawable(R.drawable.bg_sch_normal));
                    }
                } else {
                    holder.comename_tv.setVisibility(View.GONE);
                }
            }
        }

        if ("3".equals(isEnd) && "1".equals(mMap.get(ScheduleTable.schRead))) {
            if (Integer.valueOf(mList.get(position).get(ScheduleTable.schcRecommendId)) > 0
                    && Integer.valueOf(mList.get(position).get(ScheduleTable.schAID)) == 0) {
                holder.new_img.setBackground(context.getResources().getDrawable(R.mipmap.icon_diandian));
                holder.new_img.setVisibility(View.VISIBLE);
                holder.timeall_tv_lastday.setVisibility(View.GONE);
                holder.guoqi_img.setVisibility(View.GONE);
                holder.newcome_ll.setVisibility(View.GONE);
                holder.comename_tv.setVisibility(View.GONE);
            } else {
                holder.newcome_ll.setVisibility(View.VISIBLE);
                holder.newcome_tv.setVisibility(View.VISIBLE);
                holder.newcome_tv.setText("已修改");
                holder.new_img.setVisibility(View.GONE);
            }
        } else if ("0".equals(isEnd)
                && "1".equals(mMap.get(ScheduleTable.schRead))) {
            if (Integer.valueOf(mList.get(position).get(ScheduleTable.schcRecommendId)) > 0
                    && Integer.valueOf(mList.get(position).get(ScheduleTable.schAID)) == 0) {
                holder.new_img.setBackground(context.getResources().getDrawable(R.mipmap.icon_new));
                holder.new_img.setVisibility(View.VISIBLE);
                holder.timeall_tv_lastday.setVisibility(View.GONE);
                holder.guoqi_img.setVisibility(View.GONE);
                holder.newcome_ll.setVisibility(View.GONE);
                holder.comename_tv.setVisibility(View.GONE);
            } else {
                holder.newcome_ll.setVisibility(View.VISIBLE);
                holder.newcome_tv.setVisibility(View.VISIBLE);
                holder.newcome_tv.setText("New!");
                holder.new_img.setVisibility(View.GONE);
            }

        } else if ("2".equals(isEnd)
                && "1".equals(mMap.get(ScheduleTable.schRead))) {
            if (Integer.valueOf(mList.get(position).get(ScheduleTable.schcRecommendId)) > 0
                    && Integer.valueOf(mList.get(position).get(ScheduleTable.schAID)) == 0) {
                holder.new_img.setBackground(context.getResources().getDrawable(R.mipmap.icon_diandian));
                holder.new_img.setVisibility(View.VISIBLE);
                holder.timeall_tv_lastday.setVisibility(View.GONE);
                holder.guoqi_img.setVisibility(View.GONE);
                holder.newcome_ll.setVisibility(View.GONE);
                holder.comename_tv.setVisibility(View.GONE);
            } else {
                holder.newcome_ll.setVisibility(View.VISIBLE);
                holder.newcome_tv.setVisibility(View.VISIBLE);
                holder.newcome_tv.setText("已删除");
                holder.new_img.setVisibility(View.GONE);
            }
        } else {
            if (Integer.valueOf(mList.get(position).get(ScheduleTable.schcRecommendId)) <= 0
                    && Integer.valueOf(mList.get(position).get(ScheduleTable.schAID)) != 0) {
                holder.new_img.setVisibility(View.GONE);
            }
            holder.newcome_ll.setVisibility(View.GONE);
            holder.newcome_tv.setVisibility(View.GONE);
        }


        return convertView;
    }

    class ViewHolder {
        SwipeLayout swipeLayout;
        LinearLayout top_ll, timeall_ll, timeall_rela_right, datebackground_ll, select_cb_ll, outweek_ll, newcome_ll;
        TextView timeall_tv_month, timeall_tv_week, timeall_tv_daycount, timeall_tv_time, timeall_tv_shun, timeall_tv_lastday, timeall_tv_content,
                personstate_tv, tv_delete, comename_tv, timeall_tv_nongli, bottom_month, bottom_week, outweekcount_tv, newcome_tv, timeall_after;
        ImageView guoqi_img, new_img;
        CheckBox select_cb;
    }


    public void setNewState(List<LyNewNumBean.ListBean> listBean) {
        listBeanList.clear();
        listBeanList.addAll(listBean);
        notifyDataSetChanged();
    }

    private int measureTextViewHeight(String text, int textSize, int deviceWidth) {
        TextView textView = new TextView(context);
        textView.setText(text);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(deviceWidth,
                View.MeasureSpec.AT_MOST);
        int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0,
                View.MeasureSpec.UNSPECIFIED);
        textView.measure(widthMeasureSpec, heightMeasureSpec);
        return textView.getMeasuredHeight();
    }

    public void setData(List<Map<String, String>> list) {
        this.mList = list;
        notifyDataSetChanged();
    }
}
